import {COMMON_API} from '../../../config.js';
 const API = COMMON_API;

function getRese(index) {
    var role_code = sessionStorage.getItem('role_code');
    if (role_code != null && role_code !=''){
        index = role_code;
    }
    $.ajax({
        url: HOST_ADDR + '/cpmp/pageresources/bycode/'+index,
        type: 'get',
        // data: JSON.stringify(data),
        dataType: 'json',
        contentType: "application/json",
        success: function (resp) {
            $.each(resp,function(idx,item){
                let rese_name = item.rese_name;
                $('.J_main-menu .title').each(function (index, menu) {
                    if ($(menu).html().indexOf(rese_name) > -1) {
                        $(menu).parents('.J_main-menu').removeClass('hidden');
                    }
                });

                $('.J_sub-menu-item a').each(function (index, menu) {
                    console.log(menu);
                    if ($(menu).html().indexOf(rese_name) > -1) {
                        $(menu).parents('.J_main-menu').removeClass('hidden');
                        $(menu).parents('.J_sub-menu-item').removeClass('hidden');
                    }
                })
            })

        },
        error: function (err) {
            console.log(err);
        }
    })
}


// var role_code = sessionStorage.getItem('role_code');
// if (role_code != null && role_code !=''){
//     getRese(role_code);
// }

console.log('common.js');

export{
    getRese
}